class GameStats:
    """创建一个游戏统计的类，统计信息都保存在这里"""

    def __init__(self, ai_settings):
        """初始化统计信息"""
        self.ai_settings = ai_settings
        self.ships_left = self.ai_settings.ship_limit
        self.score = 0
        # 在任何时候都不应该重置最高分，后续应该这个值从文件中读取
        with open("high_score.txt") as f:
            self.high_score = int(f.read())
        # 文件中保存的最高分
        self.file_high_score = self.high_score
        # 游戏等级
        self.level = 1
        # 游戏是否要处于启动状态
        self.game_active = False
        self.reset_stats()

    def reset_stats(self):
        """初始化在游戏运行期间可能发生变化的统计信息"""
        self.ships_left = self.ai_settings.ship_limit
        self.score = 0
        self.level = 1
